package com.example.michong;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author michong
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
@MapperScan("com.example.mochong.mapper")
public class BaseApplication {

    public static void main(String[] args) {
        SpringApplication.run(BaseApplication.class, args);
    }

    @Bean
    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
        redisTemplate.setConnectionFactory(factory);
        RedisSerializer stringSerializer = new StringRedisSerializer();
//        RedisSerializer redisObjectSerializer = new RedisObjectSerializer();
//        redisTemplate.setKeySerializer(stringSerializer);
//        redisTemplate.setHashKeySerializer(stringSerializer);
        Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
        redisTemplate.setHashValueSerializer(serializer);
//        redisTemplate.setValueSerializer(redisObjectSerializer);
        redisTemplate.afterPropertiesSet();
        return redisTemplate;
    }
}
/*
* List of unsupported commands: DUMP, RESTORE, AUTH
Connecting ...

Connected.
47.105.202.118:0>info
"# Server
redis_version:5.0.3   redis版本
redis_mode:standalone  模式: 集群master/单机standalone
os:Linux 4.18.0-193.14.2.el8_2.x86_64 x86_64   操作系统
tcp_port:6379  端口:
uptime_in_days:29  已启动时间 天
executable:/usr/bin/redis-server  执行文件
config_file:/etc/redis.conf 配置文件

# Clients
connected_clients:110  客户端连接数

# Memory  数据单位默认字节   后缀带"human" 换了单位的数据
used_memory:4110472  数据占用内存
used_memory_human:3.92M
used_memory_rss:12095488 物理内存总理
used_memory_rss_human:11.54M
used_memory_peak:7305240  内存使用峰值值

total_system_memory:8189603840 系统内存
total_system_memory_human:7.63G

maxmemory:0 可使用最大内存
maxmemory_human:0B
*
* 使用内存占比计算公式  (used_memory + used_memory_rss)/maxmemory 如果maxmemory=0 则用total_system_memory

mem_fragmentation_ratio:2.97  内存碎片率


# Persistence

rdb_last_save_time:1652406148  RDB: 是否开启 有数据则为开启
aof_enabled:0                  AOF 是否开启  0开启/1未开启

# Stats
instantaneous_input_kbps:0.00  每秒输入kb数量
instantaneous_output_kbps:0.00 每秒输出kb数量

evicted_keys:0 内存超出时，被逐出的Key数量
keyspace_hits:610459 自redis启动开始，成功命中的key数量
keyspace_misses:108299 自redis启动开始，未成功名称的key数量


# Cluster
cluster_enabled:0  是否启用集群，0=未启用，1=启用




 */